package main 
{
	import assists.Lang;
	import assists.resource.ResourceLoader;
	
	import flash.display.Sprite;
	
	import inerface.IMessage;
	import inerface.IPanel;
	
	import views.ViewLayout;
	
	/**
	 * ...
	 * @author clouree
	 */
	public class ViewSubBase extends SuperSubBase
	{
		private var _viewManager:ViewManager;
		
		public function ViewSubBase()
		{
			
		}
		
		override public function initComponents(value:SuperBase):void
		{
			if (!value)
			{
				trace("传入组件为空");
				return;
			}
			_viewManager = value as ViewManager;
			
		}
		
		protected function get layout():ViewLayout
		{
			return _viewManager.layout;
		}
		
		protected function get view():ViewManager
		{
			return _viewManager;
		}
		
		protected function get data():DataManager
		{
			return _viewManager.dataManager;
		}
		
		protected function get resourceLoader() : ResourceLoader
		{
			return _viewManager.resourceLoader;
		}
		
		protected function get lang():Lang
		{
			return _viewManager.lang;
		}
		
		protected function addView(container:IPanel):void
		{
			_viewManager.layout.addView(this,container);
		}
		
		protected function closeView(value:ViewSubBase):void
		{
			_viewManager.layout.closeView(value);
		}
		
		public function show():void
		{
			
		}
		
		protected function render():void
		{
			
		}
		
		/*关闭视图函数*/
		public function close():void
		{
			_viewManager.layout.closeView(this);
		}
		
		/*清理函数*/
		public function clear():void
		{
			_viewManager.destroyObject(this as Class);
		}
		
		public function send(message:IMessage):void
		{
			_viewManager.dataManager.send(message);
		}
		
		public function registerMessageHandler(messageId:uint,callBack:Function):void
		{
			_viewManager.dataManager.registerMessageHandler(messageId,callBack)
		}
		
		public function cancelMessageHandler(messageId:uint,callBack:Function):void
		{
			_viewManager.dataManager.cancelMessageHandler(messageId,callBack);
		}
		
		public function get instage():Boolean
		{
			var bool:Boolean = _viewManager.layout.instage(this);
			return bool;
		}
	}
}